package com.ejianlong.tongchuang.myhiltdemo.bean

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import javax.inject.Inject
import javax.inject.Qualifier

interface Horn {
    fun sounded()
}


class NormalHorn @Inject constructor() : Horn {

    override fun sounded() {
        println("NormalHorn sounded")
    }

}

class GoodHorn @Inject constructor() : Horn {

    override fun sounded() {
        println("goodHorn sounded")
    }

}

@Module
@InstallIn(ActivityComponent::class)
abstract class HornModule {

    @BindNormalHorn
    @Binds
    abstract fun bindNormalHorn(normalHorn: NormalHorn): Horn

    @BindGoodHorn
    @Binds
    abstract fun bindGoodHorn(goodHorn: GoodHorn): Horn


}

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class BindNormalHorn


@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class BindGoodHorn

